#ifndef THUMBNAILBARWIDGET_H
#define THUMBNAILBARWIDGET_H

#include <QWidget>
#include <QBoxLayout>
class ImageInstance;
class SeriesInstance;
class DicomImageLabel;
class ImageLoadThread;
struct StudyRecord;
class DcmFileFormat;

class ThumbnailBarWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ThumbnailBarWidget(QWidget *parent = 0);
    ~ThumbnailBarWidget() { clear(); }

    void setBarDirection(QBoxLayout::Direction direction) { layout->setDirection(direction); }
    DicomImageLabel *getCurrentImageLabel() const { return currentImageLabel; }

    QList<SeriesInstance*> getSeriesList() const;
    int getNumberOfLabels() const { return imageLabelList.size(); }
    QSize sizeHint() const;

signals:
    void currentChanged(DicomImageLabel *label);
    void imageDoubleClicked(DicomImageLabel *label);
    void seriesInserted(SeriesInstance *series);

public slots:
    void setCurrentImageLabel(const SeriesInstance *series);
    void appendImageFiles(const QStringList &files, bool clearOld = false);
    void appendFileFormat(DcmFileFormat *dcmff);
    void setImageFiles(const QStringList &files) { appendImageFiles(files, true); }
    void clear();

    void updateLabelImage(const SeriesInstance *series);

protected slots:
    void onImageReady(ImageInstance *image);
    void onImageClicked(DicomImageLabel *imageLabel);
    void onImageDoubleClicked(DicomImageLabel *imageLabel);
    void onLoadFinished();

protected:
    void keyPressEvent(QKeyEvent *e);

private:
    QBoxLayout *layout;
    QList<DicomImageLabel*> imageLabelList;
    DicomImageLabel *currentImageLabel;
};

#endif // THUMBNAILBARWIDGET_H
